/**
 * @file	simpleBLEperipheral.h
 * @author	chipsea
 * @brief	This file contains the Simple BLE Peripheral sample application
 *			definitions and prototypes.
 * @version 0.1
 * @date 2020-11-30
 * @copyright Copyright (c) 2020, CHIPSEA Co., Ltd.
 * @note
 */
#ifndef SIMPLEBLEPERIPHERAL_H
#define SIMPLEBLEPERIPHERAL_H

#ifdef __cplusplus
extern "C"
{
#endif

/*********************************************************************
 * INCLUDES
 */

/*********************************************************************
 * CONSTANTS
 */


// Simple BLE Peripheral Task Events
#define SBP_START_DEVICE_EVT                           	0x0001
#define SBP_PERIODIC_EVT                               	0x0002
#define SBP_NOTIFY_TEST_EVT								0x0004
#define SBP_RESET_ADV_EVT                              	0x0008
//#define SBP_DLE_CHANGE_EVT                             0x0020
//#define SBP_PHY_UPDATE_EVT                             0x0040
//#define SBP_CONN_NOTIFY_EVT                            0x0080

/*********************************************************************
 * MACROS
 */
// FFF5 write command definition
#define CMD_SET_ADV_IND_INTERVAL			0xFF		//cmd+interval(1B), unit time is 5ms
#define CMD_SET_ADV_NONCONN_IND_INTERVAL	0xFE		//cmd+interval(1B), unit time is 5ms
#define CMD_PRINT_PER_INFO					0xFD		//cmd
#define CMD_SLEEP							0xFC		//cmd+param(1B), 0-poweroff, otherwise-sleep time, unit time is 1s

#define CMD_START_NOTIFY_TEST				0x00		//cmd+notifyInterval(1B)+notifyPktNum(1B), notifyInterval bit[7] is connect event flag, bit[6:0] is interval. 
														//notify characteristic is FFF6
#define CMD_SET_CONN_PARAMETER				0x01		//cmd+connIntvMin(1B)+connIntvMax(1B)+connIntvLatency(1B)+connTimeOut(1B), connIntv unit time is 5ms, connTimeOut is 1s
#define CMD_SET_MTU_SIZE_MAX				0x02		//cmd+mtu_size(1B)
#define CMD_SET_DLE_LENGTH					0x03		//cmd+pduLen(1B)
#define CMD_SET_PHY_MODE					0x05		//cmd+allPhy(1B)+txrxPhy(1B)+defPhy(1B)

#define DEFAULT_IBEACON_UUID				0x07, 0x64, 0x78, 0x25, 0xFD, 0xA5, 0x06, 0x93, 0xA4, 0xE2, 0x4F, 0xB1, 0xAF, 0xCF, 0xC6, 0xEB
#define DEFAULT_IBEACON_MAJOR				0xFE23
#define DEFAULT_IBEACON_MINOR				0x4839
#define	DEFAULT_IBEACON_POWER				0xC4		//-60dBm

/*********************************************************************
 * FUNCTIONS
 */

/**
 * @fn		void SimpleBLEPeripheral_Init( uint8 task_id )
 * @brief	Task Initialization for the BLE Application
 */
extern void SimpleBLEPeripheral_Init( uint8 task_id );

/**
 * @fn		uint16 SimpleBLEPeripheral_ProcessEvent( uint8 task_id, uint16 events )
 * @brief	Task Event Processor for the BLE Application
 */
extern uint16 SimpleBLEPeripheral_ProcessEvent( uint8 task_id, uint16 events );

/*********************************************************************
*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif /* SIMPLEBLEPERIPHERAL_H */
